/*
 * @Author: Lw
 * @Date: 2022-08-29 10:28:41
 * @LastEditors: Lw
 * @LastEditTime: 2022-09-01 11:39:18
 */
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {NaiveUiResolver} from 'unplugin-vue-components/resolvers'
import {resolve} from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    hmr: {overlay: false},
    host: true,
    port: 9000,
    proxy: {
      '/api': {
        target: 'http://172.168.10.192:11001/',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, ''),
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve('src'),
    },
  },
  plugins: [
    vue(),
    AutoImport({
      imports: [
        'vue',
        'vue-router',
        {
          'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar'],
        },
        // {dayjs: [['*', '$dayjs']]},
        // {
        //   '@/http/index.js': [
        //     ['get', '$get'],
        //     ['post', '$post'],
        //     ['del', '$del'],
        //     ['upload', '$upload'],
        //   ],
        // },
        // {'@/assets/js/lodash.js': ['$debounce', '$throttle']},
        // {'@/assets/js/toast.js': [['*', '$toast']]}, // import { * as $toast } from '@/assets/utils/toast.js'
      ],
    }),
    Components({
      resolvers: [NaiveUiResolver()],
    }),
  ],
  // css: {
  //   //css预处理
  //   preprocessorOptions: {
  //     scss: {
  //       additionalData: '@import "@/style.scss";',
  //     },
  //   },
  // },
})
